<?php

namespace app\api\controller\carbon\knowledge;

use app\common\controller\Api;
use think\Db;

/**
 * 核算接口
 */
class Info extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 获取科普知识列表
     *
     */
    public function index($type_id = 0)
    {
        $where = [];
        if ($type_id != 0) {
            $where = array(
                'type_id' => $type_id
            );
        }
        $list = model('app\admin\model\carbon\knowledge\Info')
            ->where($where)
            ->paginate();
        $this->success('获取成功', $list);
    }


    /**
     * 获取科普知识详情
     *
     */
    public function activeInfo($id)
    {

        $activeInfo = model('app\admin\model\carbon\knowledge\Info')
            ->where("id", $id)
            ->find();
        $this->success('获取成功', $activeInfo);
    }


    /**
     * 记录浏览
     *
     */
    public function activeLog($id)
    {
        model('app\admin\model\carbon\knowledge\Info')->where("id", $id)->setInc("num");
    }
}
